package ioc15;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;

public class SomeBeanPropertyPostProcessor implements BeanPostProcessor {

    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        System.out.println("SomeBeanPropertyPostProcessor.postProcessBeforeInitialization()");

        // if("someBean".equals(beanName)){
        //
        // }

        if(bean instanceof SomeBean){
            SomeBean someBean= (SomeBean) bean;

            someBean.setStr(someBean.getStr().toUpperCase());
        }

        return bean;
        // return "abc";
    }


    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        System.out.println("SomeBeanPropertyPostProcessor.postProcessAfterInitialization()");
        return bean;
    }
}
